import React, { useEffect, useState } from 'react';
import { ReloadOutlined, SmileOutlined } from '@ant-design/icons';
import { Button, Result } from 'antd';
import { parse } from '@/utils/historyUtils';
import { currentAccount } from '@/services/api/api-login';
import { history } from '@umijs/max';

const ResultState: React.FC = () => {
    const [url, setUrlState] = useState('')
    useEffect(() => {
        const { url } = parse(location.search) as { url: string };
        console.log(url);
        setUrlState(url)
    }, [])
    const reload = async () => {
        try {
            const msg = await currentAccount({
                skipErrorHandler: true,
            });
            if (url === '/state'||url===undefined) {
                history.push('/')
            } else {
                history.push(url)
            }
        } catch (error) {

        }
    }
    return (
        <>
            <Result
                icon={<SmileOutlined />}
                title="系统更新维护中，请稍后再试"
                extra={<Button type="primary" icon={<ReloadOutlined />} onClick={() => reload()}>刷新重试</Button>}
            />
        </>
    )
}

export default ResultState;